package com.sugar.real.estate.module.business.controller.app.dicttype;

import com.sugar.real.estate.framework.common.pojo.CommonResult;
import com.sugar.real.estate.module.business.controller.admin.dicttype.vo.BizDictDataSimpleRespVO;
import com.sugar.real.estate.module.business.service.dicttype.BizDictTypeService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import java.util.List;
import java.util.Map;

import static com.sugar.real.estate.framework.common.pojo.CommonResult.success;

@Tag(name = "APP - 字典类型")
@RestController
@RequestMapping("/biz/biz-dict-type")
@Validated
public class AppBizDictTypeController {

    @Resource
    private BizDictTypeService bizDictTypeService;

    @GetMapping("/data/{typeId}")
    @PermitAll
    public CommonResult<List<BizDictDataSimpleRespVO>> getAllDictDataByTypeId(@PathVariable("typeId") Long typeId) {
        return success(bizDictTypeService.appGetAllDictDataByTypeId(typeId));
    }

    @GetMapping("/data/all")
    public CommonResult<Map<String, List<BizDictDataSimpleRespVO>>> getAllDictDataAll() {
        return success(bizDictTypeService.appGetAllDictDataAll());
    }
}